package kr.co.handysoft.common.profiler;

import java.util.Enumeration;
import java.util.Properties;

import kr.co.handysoft.common.compress.Archiving;

import net.sf.json.JSONObject;

public class EnvCommand extends AbstractCommand{

	@Override
	public String invoke() {
		
		this.command = "ENV";
		
		JSONObject retJSON = new JSONObject();
		Properties sysProp = System.getProperties();
		Enumeration<Object> keyEnum = sysProp.keys();
		
		while(keyEnum.hasMoreElements()){
			String keyString = (String) keyEnum.nextElement();
			String propString = sysProp.getProperty(keyString);
			retJSON.put(keyString, propString);
		}
		
		String replaceDirectory = retJSON.toString().replaceAll("\\\\", "/").replace("//", "/");
		
		return Archiving.send(replaceDirectory);
	}

}

